<?php
$loader->requireOnce('includes/InPayment/InPaymentData.class.php');
class ExtInPaymentData extends InPaymentData {
    protected $advancePayment   =   0;
    protected $patientDebt      =   0;

    public function __construct($orgPrice=0, $insPrice=0, $patPrice=0,
            $advancePayment=0) {
        $this->originalPrice    =   $orgPrice;
        $this->insurancePrice   =   $insPrice;
        $this->patientPrice     =   $patPrice;
        $this->advancePayment   =   $advancePayment;
    }

    public function setAdvancePayment($val) {
    	$this->advancePayment  =   $val;
    }

    public function getAdvancePayment($localized=false){
        if ($localized) {
            return L10nHelper::renderNumber($this->advancePayment);
        }
    	return $this->advancePayment;
    }

    public function getPatientDebt($localized=false){
        $debt   =   $this->patientPrice - $this->advancePayment;
        if ($localized) {
            return L10nHelper::renderNumber($debt);
        }
        return $debt;
    }

    public function getAbsolutePatientDebt($localized=false){
    	$debt  =   abs($this->getPatientDebt());
    	if ($localized) {
            return L10nHelper::renderNumber($debt);
        }
        return $debt;
    }

    public function toArray($localized){
    	$res   =   array();
    	$res['patientId']     =    $this->getPatientId();
    	$res['insuranceType'] =    $this->getInsuranceType();
    	$res['originalPrice'] =    $this->getOriginalPrice($localized);
    	$res['insurancePrice']=    $this->getInsurancePrice($localized);
    	$res['patientPrice']  =    $this->getPatientPrice($localized);
    	$res['advancePayment']=    $this->getAdvancePayment($localized);
    	$res['patientDebt']   =    $this->getPatientDebt($localized);
        $res['absolutePatientDebt']   =    $this->getAbsolutePatientDebt($localized);

    	return $res;
    }
}
?>